#!/usr/bin/env python

"""
*****************************************************************
message.py
This file is part of s60console project.

Released under GNU GPLv2.
See accompanying gpl-2.0.txt file
or visit http://www.gnu.org/licenses/gpl-2.0.txt

Author: Kashif Iftikhar (kashif [at] compulife.com.pk)

Description:
------------
Contains the Message class

*****************************************************************
"""

class Message:
    "Class representing an SMS or MMS message"
    
    def __init__(self, msg_type='SMS', sender_name='', sender_phone='', receiver_name='', receiver_phone='',
                 msg_date = '', folder='INBOX', msg_direction='RECEIVED', message=''):
        self.msg_type = msg_type
        self.sender_name = sender_name
        self.sender_phone = sender_phone
        self.receiver_name = receiver_name
        self.receiver_phone = receiver_phone
        self.msg_date = msg_date
        self.folder = folder
        self.msg_direction = msg_direction
        self.message = message
    
    def __repr__(self):
        ret = "Message(msg_type='%s', " % self.msg_type
        ret += "sender_name='%s', sender_phone='%s', " % (self.sender_name, self.sender_phone)
        ret += "receiver_name='%s', receiver_phone='%s', " % (self.receiver_name, self.receiver_phone)
        ret += "msg_date='%s', " % str(self.msg_date)
        ret += "folder='%s', " % self.folder
        ret += "msg_direction='%s', " % self.msg_direction
        ret += "message='%s')" % self.message
        
        return ret

    def __str__(self):
        ret = "\nMessage Type: " + self.msg_type
        ret += "\nSender: %s (%s)" % (self.sender_phone, self.sender_name)
        ret += "\nReceiver: %s (%s)" % (self.receiver_phone, self.receiver_name)
        ret += "\nDate/Time: %s " % str(self.msg_date)
        ret += "\nFolder: " + self.folder
        ret += "\nDirection: " + self.msg_direction
        ret += "\nMessage Content: " + self.message
        
        return ret
    
    
def _tests():
    "Test cases for the module"
    "Test cases for the module"
    import sput
    
    T = sput.tester()
    
    #def _test_parse_command():
    #    "Unit tests for the parse_command function"
    #    cmd = "sendsms +92343545454 This is just a simple msg"
    #    valid_r = {'message': ' This is just a simple msg', 'cmd': 'SENDSMS', 'contact': '+92343545454'}
    #    T.add_test("****** prase_command test. single line message command: %s" % cmd, parse_command, valid_r, cmd)
    #
    #
    #_test_parse_command()
    
    T.run_all_tests()

if __name__ == '__main__':
    import sys
    if len(sys.argv)>1 and 'run_tests'==sys.argv[1]:
        _tests()
    